<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>上传图片</title>
<link rel=stylesheet type="text/css" href="Public/js/uploadify/uploadify.css" />
<script type="text/javascript" src="Public/js/jquery-1.7.js"></script>
<script type="text/javascript" src="Public/js/uploadify/swfobject.js"></script>
<script type="text/javascript" src="Public/js/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript" src="Public/js/jspopup/popup.js"></script>
<literal>
<script type="text/javascript">
$(document).ready(function(){
	var size=$("#MaxFileSize").val();
	size=size*1024*1024;
	var manUrl=$("#manUrl").val();
	$("#uploadify").uploadify({
		'uploader':'Public/js/uploadify/uploadify.swf',
		'script':manUrl,
		//'folder':'Upload',
		'queueID':'fileQueue',
		//'hideButton':true,
		'sizeLimit':size,
		'buttonText':'Add File...',
		//'buttonImg':'',
		//'buttonImg':'',
		//'buttonImg':'',
		'width':120,
		'height':25,
		'auto':false,
		'multi':true,
		'cancelImg':'Public/js/uploadify/cancel.png',
		'onSelect':function(e,queueId,fileOb){
			//var str="文件名:"+fileOb.name+"|文件大小:"+fileOb.size+"|创建时间:"+fileOb.creationDate+"|文件类型:"+fileOb.type;
			//alert(str);
			var imageinfo=$("#imageInfo").val();
			if(imageinfo){
				imageinfo=imageinfo.split("|");
				var isY='n';
				for(var i=0;i<imageinfo.length;i++){
					if(imageinfo[i]==fileOb.name){
						isY='y';
						break;
					}
				}
				if(isY=='n'){
					$("#imageInfo").val($("#imageInfo").val()+"|"+fileOb.name);
				}
			}else{
				$("#imageInfo").val(fileOb.name);
			}
			
			
		},
		'onCancel':function(e,queueId,fileOb){
			//var str="文件名:"+fileOb.name+"|文件大小:"+fileOb.size+"|创建时间:"+fileOb.creationDate+"|文件类型:"+fileOb.type;
			//alert(str);
			var out=[];
			var imageinfo=$("#imageInfo").val();
			if(imageinfo){
				imageinfo=imageinfo.split("|");
				var isY='n';
				for(var i=0;i<imageinfo.length;i++){
					if(imageinfo[i]==fileOb.name){
						
					}else{
						out.push(imageinfo[i]);
					}
				}
				$("#imageInfo").val(out.join("|"));
			}
		},
		'onComplete':function(e,queueId,fileOb,response,data){
			var _y=parseInt(response);
			if(_y>=1){
				
			}else{
				var out=[];
				var imageinfo=$("#imageInfo").val();
				if(imageinfo){
					imageinfo=imageinfo.split("|");
					var isY='n';
					for(var i=0;i<imageinfo.length;i++){
						if(imageinfo[i]==fileOb.name){
							
						}else{
							out.push(imageinfo[i]);
						}
					}
					$("#imageInfo").val(out.join("|"));
				}
			}
		},
		'onAllComplete':function(event,data){
			//alert("ok");
			//$('#imageform').attr("action","?m=Admin&a=imageSave");
			//$('#imageform').ajaxSubmit(optionsImage); 
			var gj_id=$("#g_id").val();
			var imageInfo=$("#imageInfo").val();
			$.ajax({
				   type: "POST",
				   url: "?m=Admin&a=imageSave",
				   data: "g_id="+encodeURIComponent(gj_id)+"&imageInfo="+encodeURIComponent(imageInfo),
				   success: function(msg){
				     var _ok=parseInt(msg);
				     if(_ok>=1){
				    	 parent.window.location.reload(); 
				     }else{
				    	 pAlert("信息提示","上传失败");
				     }
				   }
				}); 
		}
	
	});
	
});


function pAlert(title,content){
	 var pop=new Popup({ isClose:true,contentType:4,isReloadOnClose:false,width:200,height:50,isSupportDraging:false,isBackgroundCanClick:true});
    pop.setContent("title",title);
    pop.setContent("alertCon",content);
    pop.build();
    pop.show();
}
</script>
</literal>
<style>
a.hover {
	color: red;
}
 
#demo-list {
	padding: 0;
	list-style: none;
	margin: 0;
}
 
#demo-list .file-invalid {
	cursor: pointer;
	color: #514721;
	padding-left: 48px;
	line-height: 24px;
	background: url(Public/js/fancyUpload/assets/error.png) no-repeat 24px 5px;
	margin-bottom: 1px;
}
#demo-list .file-invalid span {
	background-color: #fff6bf;
	padding: 1px;
}
 
#demo-list .file {
	line-height: 2em;
	padding-left: 22px;
	background: url(Public/js/fancyUpload/assets/attach.png) no-repeat 1px 50%;
}
 
#demo-list .file span,
#demo-list .file a {
	padding: 0 4px;
}
 
#demo-list .file .file-size {
	color: #666;
}
 
#demo-list .file .file-error {
	color: #8a1f11;
}
 
#demo-list .file .file-progress {
	width: 125px;
	height: 12px;
	vertical-align: middle;
	background-image: url(Public/js/fancyUpload/assets/progress-bar/progress.gif);
}
.style2 {font-size: 14px;
	font-weight: bold;
	color: #345BA4;
}
body{font-size:12px;}
</style>
</head>
<body>
<div>
<input type="hidden" id="MaxFileSize" value="{$MaxFileSize}">
<input type="hidden" id="manUrl" value="{$manUrl}">
	<div>
		<div id="fileQueue" style="height:300px;background-color:#F5F5F5;overflow-y:auto;"></div>
		
		<div style="height:28px;line-height:28px;background-color:#2E5168;text-align:right;">
		<form id="imageform" name="imageform" method="post">
		<h3><input type="file" name="uploadify" id="uploadify">
		<a href="javascript:$('#uploadify').uploadifyUpload();"><font style="color:#fff">[上传]</font></a>
		<a href="javascript:$('#uploadify').uploadifyClearQueue()"><font style="color:#fff">[取消]</font></a></h3>
		<input type="hidden" id="g_id" name="data[g_id]" value="{$gid}">
		<input type="hidden" id="imageInfo" name="data[imageInfo]" value="">
		<input type="submit" id="submitImage" style="display:none">
		</form>
		</div>
	</div>
</div>
</body>
</html>